import rclpy
from rclpy.node import Node
from base_interfaces_demo.srv import AddInts

class Server(Node):
    def __init__(self):
        super().__init__("server")

        self.srv = self.create_service(AddInts,'AddServer',self.add_callback)
        self.get_logger().info("server start")

    def add_callback(self,request,response):
        pass
        response.sum = request.num1 + request.num2
        self.get_logger().info('请求数据:(%d,%d),响应结果:%d' % (request.num1, request.num2, response.sum))
        return response

def  main():
    rclpy.init()
    server = Server()
    rclpy.spin(server)

    rclpy.shutdown()

if __name__ == "__main___":
    main